﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using S4Store.Domain;
using S4Store.Domain.CarKpi;
using S4Store.Domain.SellerKpi;

namespace S4Store.Models.CarKpi
{
    public class InputCarKpiDayDataModel
    {
        public List<CarBrand> CarBrands { get; set; }
        public List<CarKpiDayData> DayDatas { get; set; }
        public DateTime Date { get; set; }
        public List<CarModelMonthConfig> MonthConfigs { get; set; }

        public CarKpiDayData GetDayData(int carmodelid)
        {
            var data = DayDatas.FirstOrDefault(t => t.CarModelId == carmodelid);
            if(data==null)
            {
                data = new CarKpiDayData();
                data.Date = Date;
            }

            var carmodelconfig = MonthConfigs.FirstOrDefault(t => t.CarModelId == carmodelid);
            if(carmodelconfig!=null)
            {
                data.IsLastTenVersion = carmodelconfig.IsLastTenVersion;
                data.IsMidTenVersion = carmodelconfig.IsMidTenVersion;
                data.IsLstTenVersion = carmodelconfig.IsLstTenVersion;

            }
            return data;
        }

        public bool IsConfirmed { get; set; }

        public List<CarModel> GetCardModel(CarBrand brand)
        {
            var models = brand.EnableCarModels.Where(t => MonthConfigs.Any(x=>x.CarModelId==t.Id));
            return models.ToList();
        }
    }
}